From af8fc368d78db62f9f637e7e433d1a5027ef47b1 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Mon, 1 May 2006 17:44:51 +0100 Subject: [PATCH] Clean up compiler.h to define a few more things and update for gcc4. Signed-off-by: Keir Fraser --- xen/arch/x86/shutdown.c | 2 +- xen/include/asm-ia64/config.h | 3 --- xen/include/asm-x86/config.h | 2 -- xen/include/asm-x86/uaccess.h | 2 -- xen/include/xen/compiler.h | 28 +++++++++++++++++++--------- xen/include/xen/config.h | 3 --- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/shutdown.c b/xen/arch/x86/shutdown.c index 45085d203d..4f59b2c983 100644 --- a/xen/arch/x86/shutdown.c +++ b/xen/arch/x86/shutdown.c @@ -41,7 +41,7 @@ static inline void kb_wait(void) break; } -static void __machine_halt(void *unused) __attribute__((noreturn)) +static void __attribute__((noreturn)) __machine_halt(void *unused) { for ( ; ; ) __asm__ __volatile__ ( "hlt" ); diff --git a/xen/include/asm-ia64/config.h b/xen/include/asm-ia64/config.h index b6db2f2adf..29daf0c92f 100644 --- a/xen/include/asm-ia64/config.h +++ b/xen/include/asm-ia64/config.h @@ -79,8 +79,6 @@ extern struct page_info *mem_map; extern char _end[]; /* standard ELF symbol */ // linux/include/linux/compiler.h -#define __attribute_const__ -#define __user //#define __kernel //#define __safe #define __force @@ -98,7 +96,6 @@ extern char _end[]; /* standard ELF symbol */ // xen/include/asm/config.h //#define HZ 1000 // FIXME SMP: leave SMP for a later time -#define barrier() __asm__ __volatile__("": : :"memory") /////////////////////////////////////////////////////////////// // xen/include/asm/config.h diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h index 4ac128ff96..2b80b5643d 100644 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -63,8 +63,6 @@ name: #endif -#define barrier() __asm__ __volatile__("": : :"memory") - /* A power-of-two value greater than or equal to number of hypercalls. */ #define NR_hypercalls 64 diff --git a/xen/include/asm-x86/uaccess.h b/xen/include/asm-x86/uaccess.h index b0bca22c7b..e9004e490f 100644 --- a/xen/include/asm-x86/uaccess.h +++ b/xen/include/asm-x86/uaccess.h @@ -8,8 +8,6 @@ #include #include -#define __user - #ifdef __x86_64__ #include #else diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h index d4e5a43b2e..2cf74900dc 100644 --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -1,17 +1,21 @@ #ifndef __LINUX_COMPILER_H #define __LINUX_COMPILER_H -/* Somewhere in the middle of the GCC 2.96 development cycle, we implemented - a mechanism by which the user can annotate likely branch directions and - expect the blocks to be reordered appropriately. Define __builtin_expect - to nothing for earlier compilers. */ - -#if __GNUC__ == 2 && __GNUC_MINOR__ < 96 -#define __builtin_expect(x, expected_value) (x) +#if !defined(__GNUC__) || (__GNUC__ < 3) +#error Sorry, your compiler is too old/not recognized. #endif -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) +#define barrier() __asm__ __volatile__("": : :"memory") + +#define likely(x) __builtin_expect((x),1) +#define unlikely(x) __builtin_expect((x),0) + +#define inline __inline__ +#define always_inline __inline__ __attribute__ ((always_inline)) +#define noinline __attribute__((noinline)) + +#define __attribute_pure__ __attribute__((pure)) +#define __attribute_const__ __attribute__((__const__)) #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) #define __attribute_used__ __attribute__((__used__)) @@ -25,6 +29,12 @@ #define __must_check #endif +#if __GNUC__ > 3 +#define offsetof(a,b) __builtin_offsetof(a,b) +#else +#define offsetof(a,b) ((unsigned long)&(((a *)0)->b)) +#endif + /* This macro obfuscates arithmetic on a variable address so that gcc shouldn't recognize the original var, and make assumptions about it */ /* diff --git a/xen/include/xen/config.h b/xen/include/xen/config.h index 3356df15fb..e38cf9e366 100644 --- a/xen/include/xen/config.h +++ b/xen/include/xen/config.h @@ -10,11 +10,8 @@ #include #define EXPORT_SYMBOL(var) -#define offsetof(_p,_f) ((unsigned long)&(((_p *)0)->_f)) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#define always_inline __inline__ __attribute__ ((always_inline)) - /* Linux syslog levels. */ #define KERN_NOTICE "" #define KERN_WARNING "" -- 2.30.2